package com.aw.guiguzi.base

import com.aw.baselib.base.AwBaseApplication
import com.aw.baselib.net.download.OkHttp3Connection
import com.aw.baselib.net.download.SSLUtils
import com.aw.baselib.util.AwLog
import com.aw.guiguzi.BuildConfig
import com.aw.guiguzi.bean.NumEncloseBean
import com.aw.guiguzi.bean.NumImgItemBean
import com.aw.guiguzi.bean.NumItemBean
import com.liulishuo.filedownloader.FileDownloader

class MyApp : AwBaseApplication() {
    override fun onCreate() {
        super.onCreate()
        AwLog.setDebug(BuildConfig.DEBUG);
        FileDownloader.setupOnApplicationOnCreate(this)
            .connectionCreator(OkHttp3Connection.Creator(SSLUtils.createOkHttp()))
            .connectionCountAdapter { downloadId: Int, url: String?, path: String?, totalLength: Long ->
                1 //下载文件块数是1,解决偶现的下载任务停止问题。
            }
        FileDownloader.getImpl().setMaxNetworkThreadCount(12)
    }

    override fun needReLogin() {}
    override fun isAllowShowReloginDialog(): Boolean {
        return false
    }

    companion object {
        val instance: MyApp by lazy {
            // 注意：这里需要确保获取的是正确的实例
            AwBaseApplication.getInstance() as MyApp
        }
        @JvmField
        var mAllBettingNumsList: MutableList<NumItemBean> = ArrayList()
        @JvmField
        var mAllNumEncloseList: MutableList<NumEncloseBean> = ArrayList()
        @JvmField
        var mAllNumImitateList: MutableList<NumItemBean> = ArrayList()
        @JvmField
        var mAllBettingNumImgList: MutableList<NumImgItemBean> = ArrayList()
        @JvmField
        var mUnreadMsgCount = 0
        @JvmField
        var transactionData = ""
    }
}